using Godot;
using System;

namespace Library {
	public class CameraController2D : Camera2D {
		public enum ShakeType{
			Retro,
			Hard,
			Soft
		}
		public Node2D FollowTarget{set;get;}=null;

		bool shaking=false;
		float shakeAmp = 0;
		float shakeFreq=0;
		float shakeDuration=0;
		float shakeTime = 0;

		ShakeType shakeType=ShakeType.Hard;

		public void Shake(float amp,float freq,float duration,ShakeType type=ShakeType.Hard){
			shakeAmp=amp;
			shakeFreq=freq;
			shakeDuration=duration;
			shakeType=type;
		}

		public override void _Process(float delta) {
			if(shaking){
				shakeTime+=delta;
				if(shakeTime>=shakeDuration){
					shaking=false;
					Offset=new Vector2(0,0);
				}else{
					//TODO: Process shaking
				}
			}
			
			if(FollowTarget!=null){
				Position=FollowTarget.Position;
			}
		}
	}
}
